package 力扣日常刷题.木22一月.第09天0117;

/**
 * @author 帅小伙
 * @date 2022/1/17
 * @description
 */
public class Demo07动态规划中等等差数列划分 {



    public int numberOfArithmeticSlices(int[] nums) {
        int ans = 0;
        if(nums.length < 3) return 0;
        int d = nums[1] - nums[0];

        int t = 0;
        for (int i = 2; i < nums.length; i++) {
            if(nums[i] - nums[i-1] == d){
                t++;
            }else{
                d = nums[i] - nums[i-1];
                t = 0;
            }
            ans += t;
        }
        return ans;
    }


}
